package com.yili.oa.service.impl;

import com.yili.oa.dao.LotteryDrawConfigMapper;
import com.yili.oa.entity.SearchBase;
import com.yili.oa.models.LotteryDrawConfig;
import com.yili.oa.models.LotteryDrawConfigExample;
import com.yili.oa.service.LotteryDrawConfigService;
import com.yili.oa.utils.annotate.DataBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@DataBase("lyt_game_db")
@Transactional(value = "transactionManager")
public class LotteryDrawConfigServiceImpl implements LotteryDrawConfigService {

    @Autowired
    LotteryDrawConfigMapper mapper;

    @Override
    public List<LotteryDrawConfig> get(SearchBase searchBase) {
        LotteryDrawConfigExample example = new LotteryDrawConfigExample();
        return mapper.selectByExample(example);
    }

    @Override
    public int add(LotteryDrawConfig lotteryDrawConfig) {
        lotteryDrawConfig.setCreateTime(new Date().getTime());
        return mapper.insert(lotteryDrawConfig);
    }

    @Override
    public int update(LotteryDrawConfig lotteryDrawConfig) {
        return mapper.updateByPrimaryKeySelective(lotteryDrawConfig);
    }

    @Override
    public void delete(List<Long> ids) {
        for (Long id : ids) {
            mapper.deleteByPrimaryKey(id);
        }
    }
}
